package com.eascs.fp.uc.controller;


import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.eascs.app.dao.PageResult;
import com.eascs.fp.common.controller.BaseMasterViewController;
import com.eascs.fp.common.entity.ApplyLoanEntity;
import com.eascs.fp.common.entity.MemberEntity;
import com.eascs.fp.common.vo.ModelResult;
import com.eascs.fp.uc.form.PageForm;
import com.eascs.fp.uc.server.MemberCenterService;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.view.ViewContext;


@RequestMapping("/ucCenter")
@Controller
public class MemberCenterController extends BaseMasterViewController {
	
	@Autowired
	private MemberCenterService memberCenterService;
	
	@RequestMapping(value = "/account/index")
	public String loginIndex(HttpServletRequest request,PageForm form) {
		ModelResult<MemberEntity> memberResult=MemberRestController.isLogin(request);
		MemberEntity memberEntity=memberResult.getModel();
		ApplyLoanEntity entity=new ApplyLoanEntity();
		entity.setUserId(memberEntity.getId());
		ModelResult<PageResult<Object[]>> modelResult = memberCenterService.queryLoanApplyPage(entity, form.getPageSize(), form.getPageIndex());
		PageResult<Object[]> pageResult = modelResult.getModel();
		String[] titles = { "申请时间", "贷款类型", "申请金额", "申请期限" };
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles, "/ucCenter/account/index?pageIndex=");
		paginationInfo.setBuildPagingNavigation(true);
		paginationInfo.setFirstRenderColumnIndex(1);
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("PageForm", form);
		ViewContext.put("member", memberEntity);
		ViewContext.put("hotHM", "accountIdxHM");
		return "/uc/myAccount";
	}
	
	@RequestMapping(value = "/center/index")
	public String regIndex(HttpServletRequest request) {
		ModelResult<MemberEntity> memberResult=MemberRestController.isLogin(request);
		MemberEntity memberEntity=memberResult.getModel();
		ViewContext.put("member", memberEntity);
		ViewContext.put("hotHM", "accountIdxHM");
		return "/uc/center";
	}
	@RequestMapping(value="/scheduleInquery/index")
	public String scheduleInquery ()
	
	{
		return "uc/scheduleInquery";
		
	}
	
}
